package com.example.pingze.repository;

import com.example.pingze.entity.Creation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CreationRepository extends JpaRepository<Creation, String>, JpaSpecificationExecutor<Creation> {
    List<Creation> findCreationByTheme(String theme);

    Creation findCreationById(String id);

    @Query("select c from Creation c where c.theme = ?1 order by c.time desc")
    List<Creation> findNewCreationByTheme(String theme);

    @Query("select c from Creation c where c.theme = ?1 order by c.love desc")
    List<Creation> findHottestCreationByTheme(String theme);

    Creation findCreationByAccount(String account);
}
